package serverapp;

import java.io.Serializable;

public class DVD implements Serializable
{
	private boolean availableForRent, newRelease;
	private String category, title;
	
	public DVD()
	{
		title = "";
		category = "";
		newRelease = true;
		availableForRent = true;
	}
	
	public DVD(String t, int c, boolean n, boolean a)
	{
		title = t;
		category = Integer.toString(c);
		newRelease = n;
		availableForRent = a;
	}
	
	public void setTitle(String t)
	{
		title = t;
	}
	
	public void setCategory(int a)
	{
		//category = a;
	}
	
	public void setRelease(boolean r)
	{
		newRelease = r;
	}
	
	public void setAvailable(boolean a)
	{
		availableForRent = a;
	}	
	///////////////////////////////////////////////
	
	public String getTitle()
	{
		return title;
	}
	
	public String getCategory()
	{
		return category;
	}
	
	public boolean isNewRelease()
	{
		return newRelease;
	}
	
	public boolean isAvailable()
	{
		return availableForRent;
	}	
	
	public String toString()
	{
		// Format String to return
		String yesNo = (isNewRelease())?"Yes":"No";
		String AvailNot = (isAvailable())?"In":"Out";
		return getTitle() + "\t" + getCategory() + "\t" + yesNo + "\t" + AvailNot + "\n";
	}
	
	/*public static DVD[] sortMoives(DVD[] Movies) // This function takes in an array of DVDs, sorts them, then returns them.
	{
		DVD Temp = new DVD();
	
		for (int I = 0; I < (DVD.DVDListSize -1); I++)
		{
			for (int J = 0; J < (DVD.DVDListSize -1 -I); J++)
			if (DVD.DVDList[J].getTitle().compareTo(DVD.DVDList[J+1].getTitle()) > 0)
			{
				Temp = DVD.DVDList[J+1];
				DVD.DVDList[J+1] = DVD.DVDList[J];
				DVD.DVDList[J] = Temp;
			}
		}
		return Movies;
	}
	
	public boolean isSimilar(String StartsWith)
	{
		// System.out.println( getTitle().substring(0, (StartsWith.length())) + " " + StartsWith );
		if (getTitle().length() >= StartsWith.length())
		{
			if (getTitle().substring(0, (StartsWith.length())).toUpperCase().equals(StartsWith.toUpperCase()))
				return true;
			else
				return false;
		}
		else
			return false;
	}*/
}